package com.lsyw.intergrate.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lsyw.intergrate.common.BaseResult;
import com.lsyw.intergrate.entity.TransportWorkOrder;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lsyw.intergrate.entity.common.PageInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lsyw.intergrate.common.Result;
import org.springframework.util.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import com.lsyw.intergrate.service.TransportWorkOrderAlarmService;
import com.lsyw.intergrate.entity.TransportWorkOrderAlarm;

import java.util.*;

import io.swagger.annotations.Api;
import lombok.Data;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 运输工单告警信息 前端控制器
 * </p>
 *
 * @author 刘磊
 * @since 2023-12-14
 */
@Api(tags = "运输工单告警信息")
@RestController
@RequestMapping("/transport-work-order-alarm")
public class TransportWorkOrderAlarmController {


    @Autowired
    private TransportWorkOrderAlarmService transportWorkOrderAlarmService;


    /**
     * 通过id查询
     */
    @GetMapping("/get-by-id")
    public BaseResult<TransportWorkOrderAlarm> getById(String id) {
        return BaseResult.successResult(transportWorkOrderAlarmService.getInfoById(id));
    }

    /**
     * 通过id查询
     */
    @GetMapping("/updateStatus")
    public Result updateStatus(String id,Integer status) {
        TransportWorkOrderAlarm transportWorkOrderAlarm = transportWorkOrderAlarmService.getById(id);
        transportWorkOrderAlarm.setStatus(status);
        transportWorkOrderAlarmService.updateById(transportWorkOrderAlarm);
        return Result.successResult("");
    }

    /**
     * 分页查询
     */
    @PostMapping("/page")
    @ApiOperation(value = "运输历史记录列表-分页", notes = "运输历史记录列表-分页", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "condition:companyId", value = "运输公司/团队 ", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "condition:massifId", value = "地块Id", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "condition:name", value = "工单名称", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "condition:startTime", value = "开始时间  年-月-日", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "condition:endTime", value = "结束时间 年-月-日", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "condition:transportPlanId", value = "运输计划", required = false, paramType = "query", dataType = "String")
    })
    public BaseResult<IPage<TransportWorkOrderAlarm>> page(@RequestBody PageInfo pageInfo) {
        Page<TransportWorkOrderAlarm> page = new Page<>();
        page.setSize(pageInfo.getPageSize());
        page.setCurrent(pageInfo.getPageNum());
        return BaseResult.successResult(this.transportWorkOrderAlarmService.pageList(page, pageInfo.getCondition()));
    }


}
